#!/usr/bin/env ruby
FETCHER_ROOT = File.dirname(__FILE__)
RAILS_ENV = $*.first || "production"
puts "Rails env: #{RAILS_ENV}"
require "#{FETCHER_ROOT}/../config/environment"
require "fetcher"
while true
  begin
    puts "start fetcher"
    Fetcher.start
  rescue Exception=>e
    puts e.message
    File.open(File.join(Rails.root,"tmp","fetcher_error"),"w+") {|f| f.write(e.message + e.backtrace.join("\n"))}
  end
  sleep 30*60
end
